using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Magiq.Delete;
using Magiq.Insert;
using Magiq.Support;
using Magiq.Tests.Support;
using Magiq.Update;

namespace Magiq.Sql.Tests {
    public class MagiqMock : IMagiqProvider, IUpdateProvider, IDeleteProvider, IInsertProvider {
        public MagiqMock() {
            WasUsed = false;
        }
        public static bool WasUsed { get; private set; }
        public IUpdateProvider GetUpdateProvider() {
            return this;
        }

        public IDeleteProvider GetDeleteProvider() {
            return this;
        }

        public IInsertProvider GetInsertProvider() {
            return this;
        }

        public IQueryable<T> CreateQueryableFrom<T>(IEnumerable<T> enumerable) where T : class {
            WasUsed = true;
            return enumerable.AsQueryable();
        }

        public bool Handles(IEnumerable source) {
            return true;
        }

        public bool Handles(IEnumerable source, IEnumerable destination) {
            return true;
        }

        public IItemsAdder<T> ItemAdderFor<T, S>(IEnumerable<S> enumerable) where S : class {
            return new Adder<T>();
        }

        public int Execute<T>(IQueryableUpdate<T> update) where T : class {
            WasUsed = true;
            return 0;
        }

        public int Execute<T>(IQueryableDelete<T> delete) where T : class {
            WasUsed = true;
            return 0;
        }

        public int Execute<F, S, T>(IQueryableInsert<F, S, T> insert) where S : class {
            WasUsed = true;
            return 0;
        }

        public static void AssertWasUsed() {
            WasUsed.Should(Be.True);
        }

        private class Adder<T> : IItemsAdder<T>{
            public void Add(IEnumerable<T> items) {
                
            }
        }
    }
}